<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <title>商品评价</title>
    <style type="text/css">
        body {
            background: #fff;
            font-size: 14px;
            overflow: auto;
            margin-bottom: 55px;
        }

        .userName, .commentConent, .commentTime {
            padding: 2px 0;

        }

        .userName {
            display: block;
            color: #646464;
        }

        .commentConent {
            color: #646464;
            line-height: 16px;
            font-size: 13px;
        }

        .commentTime {
            color: #9c9c9c;
            font-size: 12px;
        }

        .commentUl li {
            padding: 10px 0;
        }
        .time{
            margin-right: 20px;
        }
    </style>
</head>
<body>
<div class="aui-content-padded">
    <div class="kongshuju">
        <p>暂无评论</p>
    </div>
    <ul class="commentUl" id="comments-content">
        <!--<li class="aui-border-b">-->
        <!--<span class="userName">硁wang思</span>-->
        <!--<div class="commentConent">满意，颜色也很正，款式很受欢迎，五分好评！满意好评！</div>-->
        <!--<div class="commentTime">2016-08-06 20:10:20 颜色:黑色;规格:12cm</div>-->
        <!--</li>-->

    </ul>
</div>

<script id="comments-template" type="text/x-dot-template">
    {{ for (var i in it) { }}
    <li class="aui-border-b">
        <span class="userName">{{=it[i].buyer}}</span>
        <div class="commentConent">{{=it[i].buyer_comment}}</div>
        <div class="commentTime"><span class="time"> {{=it[i].buyer_ctime}}</span> 规格：{{=it[i].spec}}</div>
    </li>
    {{}}}
</script>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/echo.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/myInfo.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.js"></script>
<script type="text/javascript">
    var page = 1, goodsId, isLock = false;
    apiready = function () {
        api.parseTapmode();
        goodsId = api.pageParam.itemId;
//        goodsId = 42;
        getData();
        api.setRefreshHeaderInfo({
            visible: true,
            loadingImg: 'widget://image/ptr_pull.png',
            bgColor: '#efeff4',
            textColor: '#959595',
            textDown: '下拉刷新',
            textUp: '松开刷新',
            showTime: true
        }, function (ret, err) {
            page = 1;

            getData();

            api.refreshHeaderLoadDone();
        });
        //监听是否达到底部上拉加载
        api.addEventListener({
            name: 'scrolltobottom'
        }, function (ret, err) {
            page++;
            if (isLock == false) {
                getData();
            }
        })
    }
    function changeCheck(type) {
        $("#comments-content").empty();
        page=1;
        getData();
    }
    function getData() {
        isLock = true;
        showLoading();
        data = {
            goodsId: goodsId,
            page: page
        };
        url = "User/commentList";
        ajaxRequest(url, 'post', data, function (ret, err) {
            if (ret.status == 1) {
                var content = $api.byId('comments-content');
                var tpl = $api.byId('comments-template').text;
                var tempFn = doT.template(tpl);
                if (page > 1) {
                    $api.append(content, tempFn(ret.msg));
                    isLock = false;
                } else {
                    $api.html(content, tempFn(ret.msg));
                    isLock = false;
                }
                $(".commentUl").find(".time").each(function () {
//                    var timeStamp=$(this).text();
//                    var newDate = new Date();
//                    newDate.setTime(timeStamp * 1000);
                    $(this).text(stampToTime($(this).text()))

                })
                hideLoading();
            } else {
                hideLoading();
                if (page == 1) {
                    $(".kongshuju").show();
                    $("#comments-content").empty();
                }
                isLock = true;
                api.toast({
                    msg: '暂无更多评论',
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });
    }
</script>
</html>